package com.lxc.graduation.controller;

import com.lxc.graduation.entity.domain.Topic;
import com.lxc.graduation.service.TopicService;
import com.lxc.graduation.utils.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @Author: ck
 * @Description:
 * @Date: Create in 22:17 2021/2/1
 */
@RestController
@RequestMapping("/api/pub/v1/topic")
public class TopicController {
    @Autowired
    private TopicService topicService;

    @RequestMapping("listAll")
    public JsonData listAllTopic()
    {
        return JsonData.buildSuccess(topicService.listAll());
    }

    @RequestMapping("insert")
    public JsonData insert(@RequestBody Topic topic)
    {
        topic.setCreateTime(new Date());
        topicService.insert(topic);
        return JsonData.buildSuccess("发布成功");
    }
}
